package com.handydata.antifraud.port.impl;

import com.bstek.urule.Utils;
import com.bstek.urule.runtime.KnowledgePackage;
import com.bstek.urule.runtime.service.KnowledgeService;
import com.handydata.antifraud.common.exception.RuleNotFoundException;
import com.handydata.antifraud.port.SendKnowledgePackage;
import org.springframework.stereotype.Service;

import java.io.IOException;

@Service
public class SendKnowledgePackageImpl implements SendKnowledgePackage {


    @Override
    public KnowledgePackage getKnowledgePackage(String packageName) throws RuleNotFoundException {
        KnowledgeService service = (KnowledgeService) Utils.getApplicationContext().getBean(KnowledgeService.BEAN_ID);
        com.bstek.urule.runtime.KnowledgePackage knowledgePackage = null;
        try {
            knowledgePackage = service.getKnowledge(packageName);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return knowledgePackage;
    }

}
